//
//  HomePageCell4.m
//  Mtime2.0
//
//  Created by 凉气的Mac on 16/9/5.
//  Copyright © 2016年 凉气的Mac. All rights reserved.
//

#import "HomePageCell4.h"

#import "HomePageModel.h"

#import <UIImageView+WebCache.h>

@implementation HomePageCell4

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
        
    }

    return self;
}

#pragma mark --
#pragma mark --设置界面
-(void)setupUI{
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;

    UILabel *typeLable = [[UILabel alloc]init];
    
    typeLable.textColor = [UIColor whiteColor];
    
    [self.contentView addSubview:typeLable];
    
    typeLable.font = [UIFont systemFontOfSize:12];
    
    self.typeLabel = typeLable;
    
    [typeLable mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.contentView).offset(15);
        
        make.left.equalTo(self.contentView).offset(10);
        
       // make.width.equalTo(@50);
    }];
    
    
    UIImageView *picture = [[UIImageView alloc]init];
    
    self.picture = picture;
    
    [self.contentView addSubview:picture];
    
    [picture mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(typeLable.mas_bottom);
        
        make.right.equalTo(self.contentView).offset(-15);
        
        make.width.equalTo(@120);
        
        make.height.equalTo(@75);
        
       // make.bottom.equalTo(self.contentView).offset(-40);
        
    }];
    
    UILabel *titleLabel = [[UILabel alloc]init];
    
    [self.contentView addSubview:titleLabel];
    
    titleLabel.font = [UIFont systemFontOfSize:17];
    
    titleLabel.numberOfLines = 0;
    
    [titleLabel sizeToFit];
    
    self.titleLable = titleLabel;
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(typeLable.mas_bottom).offset(5);
        
        make.left.equalTo(self.contentView).offset(10);
       
        make.right.equalTo(picture.mas_left).offset(-10);
       
    }];
    
    
    UILabel *commentLbel = [[UILabel alloc]init];
    
   // commentLbel.backgroundColor = [UIColor redColor];
    
    self.commentLbel = commentLbel;
    
    commentLbel.textColor = [UIColor colorWithWhite:0.800 alpha:1.000];
    
    commentLbel.font = [UIFont systemFontOfSize:15];
    
    commentLbel.numberOfLines = 0;
    
    [commentLbel sizeToFit];
    
    [self.contentView addSubview:commentLbel];
    
    [commentLbel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.trailing.leading.equalTo(titleLabel);
        
        make.top.equalTo(titleLabel.mas_bottom).offset(5);
        
        //make.bottom.equalTo(picture).offset(5);
    
    
    }];
    
    UILabel *timeLabel = [[UILabel alloc]init];
    
    self.timeLaber = timeLabel;
    
    timeLabel.textColor = [UIColor colorWithWhite:0.800 alpha:1.000];
    
    timeLabel.font = [UIFont systemFontOfSize:12];
    
    [timeLabel sizeToFit];
    
    [self.contentView addSubview:timeLabel];
    
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(titleLabel);
        
        make.bottom.equalTo(self.contentView).offset(-25);
        
        make.top.equalTo(commentLbel.mas_bottom).offset(10);
        
       
        
    }];
    
    
    UILabel *commentCountLabel = [[UILabel alloc]init];
    
    commentCountLabel.textColor = [UIColor colorWithWhite:0.800 alpha:1.000];
    
    self.commentCountLabel = commentCountLabel;
    
    commentCountLabel.font = [UIFont systemFontOfSize:12];
    
    [commentCountLabel sizeToFit];
    
    [self.contentView addSubview:commentCountLabel];
    
    [commentCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(timeLabel.mas_right).offset(10);
        
        make.bottom.equalTo(self.contentView).offset(-25);
        
        make.top.equalTo(commentLbel.mas_bottom).offset(10);
        
        
        
    }];

}

-(void)setModel:(HomePageModel *)model{
    
    _model = model;

    self.typeLabel.backgroundColor = [UIColor colorWithRed:0.243 green:0.578 blue:1.000 alpha:1.000];
    
    self.typeLabel.text = model.tag;
    
    self.titleLable.text = model.title;
    
    self.commentLbel.text = model.content;

    [self.picture sd_setImageWithURL:[NSURL URLWithString:model.img1]];
    
    self.timeLaber.text = [NSString stringWithFormat:@"%@",model.publishTime];
    
    self.commentCountLabel.text = [NSString stringWithFormat:@"评论  %@",model.commentCount];
    
//    if ([model.tag isEqualToString:@"影评"]) {
//        
//        self.commentLbel.text = model.summaryInfo;
//        
//    }

}



@end









































































